#include<stdio.h>
#include<string.h>

#define offsetof(TYPE, MEMBER) ((size_t)& ((TYPE *)0)->MEMBER)  
#define container_of(ptr, type, member) ({const typeof( ((type *)0)->member ) *__mptr = (ptr);(type*)((char *)__mptr - offsetof(type,member));}) 
	   
struct myclass  
{  
	int Chinese;  
	int English;       
};  

struct student  
{
	int age;
	char name[10];  
	struct myclass cla;
}stu={23,"wmqviviq", {100, 99}};
 
int main(void)
{
	struct student *p_stu = NULL;
	p_stu = container_of(&(stu.age), struct student, age);
	
	printf("age=%d\n",p_stu->age);
	printf("name=%s\n",p_stu->name);
	printf("Chinese=%d\n",p_stu->cla.Chinese);
	printf("English=%d\n",p_stu->cla.English);
}

